
package com.joysuch.wwyt.edu.enums;

import java.util.Objects;

/**
 * 培训计划状态
 *
 */
public enum TrainingPlanStates {

    NOT_STARTED(0, "未开始"), INPROGRESSING(1, "进行中"), OUT_OF_DATE(2, "已结束");

    private Integer id;
    private String name;

    private TrainingPlanStates(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public static TrainingPlanStates findByName(String name) {
        TrainingPlanStates[] values = TrainingPlanStates.values();
        for (TrainingPlanStates v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static TrainingPlanStates findById(Integer level) {
        TrainingPlanStates[] values = TrainingPlanStates.values();
        for (TrainingPlanStates v : values) {
            if (Objects.equals(v.getId(), level)) {
                return v;
            }
        }
        return null;
    }

    public static String findNameById(Integer id) {
        if (id == null) {
            return null;
        }
        TrainingPlanStates[] values = TrainingPlanStates.values();
        for (TrainingPlanStates v : values) {
            if (Objects.equals(v.getId(), id)) {
                return v.getName();
            }
        }
        return null;
    }
}
